package com.shiro.receiver.framework.constant;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

@Getter
@AllArgsConstructor
public enum BotOperationType {

    DISPATCH(               0,  "Dispatch",                 false,  true,   false , "服务端进行消息推送"),
    HTTP_CALLBACK_ACK(      12, "HTTP Callback ACK",        false,  false,  true,   "仅用于 http 回调模式的回包，代表机器人收到了平台推送的数据"),
    CALLBACK_HOST_CHECK(    13, "Callback Host Check",      false,  true,   false,  "开放平台对机器人服务端进行验证"),
    ;

    private final Integer value;
    private final String name;
    private final Boolean isSend;
    private final Boolean isReceive;
    private final Boolean isReply;
    private final String desc;

    private static final Map<Integer, BotOperationType> ENUM_MAP = new HashMap<>();

    static {
        for (BotOperationType botOperationType : BotOperationType.values()) {
            ENUM_MAP.put(botOperationType.getValue(), botOperationType);
        }
    }

    public static BotOperationType getOperationTypeByValue(Integer value) {
        return ENUM_MAP.get(value);
    }

    public static boolean isCallbackHostCheck(Integer value) {
        return CALLBACK_HOST_CHECK.getValue().equals(value);
    }

}
